﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CCWin;
namespace UI
{
    public partial class MainMenuForm : Skin_DevExpress
    {
        public bool isSignIned=false;
        public bool isSignOuted=false;
        public MainMenuForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void skinLabel1_Click(object sender, EventArgs e)
        {

        }

        private void btn_home_MouseHover(object sender, EventArgs e)
        {
            btn_home.Image = UI.Properties.Resources.白色首页;
        }

        private void btn_home_MouseLeave(object sender, EventArgs e)
        {
            btn_home.Image = UI.Properties.Resources.灰色首页;
        }

        private void btn_uinfo_MouseHover(object sender, EventArgs e)
        {
            btn_uinfo.Image = UI.Properties.Resources.员工信息2;
        }

        private void btn_uinfo_MouseLeave(object sender, EventArgs e)
        {
            btn_uinfo.Image = UI.Properties.Resources.员工信息3;
        }

        private void btn_htgl_MouseHover(object sender, EventArgs e)
        {
            btn_htgl.Image = UI.Properties.Resources.合同管理2;

        }

        private void btn_htgl_MouseLeave(object sender, EventArgs e)
        {
            btn_htgl.Image = UI.Properties.Resources.合同管理3;
        }

        private void btn_xcgl_MouseHover(object sender, EventArgs e)
        {
            btn_xcgl.Image = UI.Properties.Resources.薪酬管理2;
        }

        private void btn_xcgl_MouseLeave(object sender, EventArgs e)
        {
            btn_xcgl.Image = UI.Properties.Resources.薪酬管理3;
        }

        private void btn_gwgl_MouseHover(object sender, EventArgs e)
        {
            btn_gwgl.Image = UI.Properties.Resources.公文2;
        }

        private void btn_gwgl_MouseLeave(object sender, EventArgs e)
        {
            btn_gwgl.Image = UI.Properties.Resources.公文3;
        }

        private void btn_jxgl_MouseHover(object sender, EventArgs e)
        {
            btn_jxgl.Image = UI.Properties.Resources.绩效管理白;

        }

        private void btn_jxgl_MouseLeave(object sender, EventArgs e)
        {
            btn_jxgl.Image = UI.Properties.Resources.绩效管理灰;
        }

        private void btn_worklog_MouseHover(object sender, EventArgs e)
        {
            btn_worklog.Image = UI.Properties.Resources.工作日志2;
        }

        private void btn_worklog_MouseLeave(object sender, EventArgs e)
        {
            btn_worklog.Image = UI.Properties.Resources.工作日志3;
        }

        private void btn_worklog_Click(object sender, EventArgs e)
        {
            UI.logwork.logwork f1 = new UI.logwork.logwork();
            f1.Size = mainpanel.Size;
            f1.TopLevel = false;
            mainpanel.Controls.Clear();
            mainpanel.Controls.Add(f1);
            f1.Show();
        }

        private void btn_kqgl_MouseHover(object sender, EventArgs e)
        {
            btn_kqgl.Image = UI.Properties.Resources.考勤管理2;
        }

        private void btn_kqgl_MouseLeave(object sender, EventArgs e)
        {
            btn_kqgl.Image = UI.Properties.Resources.考勤管理3;
        }

        private void MainMenuForm_Load(object sender, EventArgs e)
        {
            InitForm f1=new InitForm();
            f1.Size = mainpanel.Size;
            f1.TopLevel=false;
            mainpanel.Controls.Add(f1);
            f1.Show();
            //===========调试===========
          //  UI.Global.uid = 20;
            //------------------------s
            Model.UserInfo  userinfo=new Model.UserInfo();
            userinfo.Uid=UI.Global.uid;
            userinfo = BLL.UserManager.staff_2(userinfo);
            label_id.Text = userinfo.Uid.ToString();
            label_job.Text = userinfo.Jobid.ToString();
            int iSex = Convert.ToInt32(userinfo.Sex);
            if (iSex == 1)
            {
                label_sex.Text = "男";
            }
            else {
                label_sex.Text = "女";
            }
           // label_sex.Text = userinfo.Sex.ToString();
            //-------------
            if (DAL.UserServer.isSignIned(UI.Global.uid) > 0)
            {
                isSignIned = true;
                btn_sign.Text = "签退";
                labelsigntext.Text = "您已签到";
            }
            if (DAL.UserServer.isSignOut(UI.Global.uid) > 0)
            {
                isSignOuted = true;
                btn_sign.Text = "签到";
                btn_sign.Enabled = false;
                labelsigntext.Text = "您今天已签退";
            }
            //--获取当前登录用户的 姓名 性别 职位 
            DataSet dts=DAL.UserServer.selectJobNameSex(UI.Global.uid);
            label_job.Text = Convert.ToString(dts.Tables[0].Rows[0]["职位"]);
            label_uname.Text = Convert.ToString(dts.Tables[0].Rows[0]["员工名字"]);
            

        }

        private void btn_gwgl_Click(object sender, EventArgs e)
        {
            UI.gongwen.gongwen f1 = new UI.gongwen.gongwen();
            f1.Size = mainpanel.Size;
            f1.TopLevel = false;
            mainpanel.Controls.Clear();
            mainpanel.Controls.Add(f1);
            f1.Show();
        }

        private void btn_uinfo_Click(object sender, EventArgs e)
        {
            UI.UserInfo.UserInfo userinfo = new UI.UserInfo.UserInfo();
            userinfo.TopLevel = false;
            mainpanel.Controls.Clear();
            mainpanel.Controls.Add(userinfo);
            userinfo.Size = mainpanel.Size;
            userinfo.Show();
        }

        private void btn_home_Click(object sender, EventArgs e)
        {

            InitForm f1 = new InitForm();
            f1.Size = mainpanel.Size;
            f1.TopLevel = false;
            mainpanel.Controls.Clear();
            mainpanel.Controls.Add(f1);
            f1.Show();
        }

        private void btn_htgl_Click(object sender, EventArgs e)
        {
            UI.hetongguanli.hetongguanli f1 = new UI.hetongguanli.hetongguanli();

            
            f1.Size = mainpanel.Size;
            f1.TopLevel = false;
            mainpanel.Controls.Clear();
            mainpanel.Controls.Add(f1);
            f1.Show();
        }

        private void btn_sign_Click(object sender, EventArgs e)
        {
            if (isSignIned == false && isSignOuted == false)
            {
                Model.UserInfo u=new Model.UserInfo();
                u.Uid=Global.uid;
                DAL.UserServer.signIn(u);
                btn_sign.Text = "签退";
                labelsigntext.Text = "您已签到";
                isSignIned = true;
            }else if (isSignIned == true && isSignOuted == false)
            {
                //签到了 没有签退
                 Model.UserInfo u=new Model.UserInfo();
                u.Uid=Global.uid;
                DAL.UserServer.signOut(u);
                isSignOuted = true;
                btn_sign.Text = "签到";
                btn_sign.Enabled = false;
                labelsigntext.Text = "您今天已签退";
            }
        }

        private void btn_xcgl_Click(object sender, EventArgs e)
        {
            xcgl.xcglForm f1 = new xcgl.xcglForm();
            f1.Size = mainpanel.Size;
            f1.TopLevel = false;
            mainpanel.Controls.Clear();
            mainpanel.Controls.Add(f1);
            f1.Show();
        }

        private void btn_jxgl_Click(object sender, EventArgs e)
        {
            UI.jixiaoguanli.jixiaoguanli f1 = new UI.jixiaoguanli.jixiaoguanli();
            f1.Size = mainpanel.Size;
            f1.TopLevel = false;
            mainpanel.Controls.Clear();
            mainpanel.Controls.Add(f1);
            f1.Show();
        }

        private void skinLabel8_Click(object sender, EventArgs e)
        {
           
        }

        private void btn_kqgl_Click(object sender, EventArgs e)
        {
            kaoqingguanli.kqglForm f1 = new kaoqingguanli.kqglForm();
            f1.Size = mainpanel.Size;
            f1.TopLevel = false;
            mainpanel.Controls.Clear();
            mainpanel.Controls.Add(f1);
            f1.Show();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label_time.Text = DateTime.Now.ToString();
        }

      

    

      

      

        
    }
}
